<template>
     <bi-switch v-model="value"  @change="handleCold"></bi-switch>
</template>

<script>
export default{
    data(){
        return {
            value:parseInt(this.cold)==1?true:false
        }
    },
    props:{
        cold:[Number,String],
        url:Object,
        storage:'',
        id:''
    },
    methods:{
        handleCold(){


            this.$ajax({
                url:this.$url(this.url),
                data:{
                    id:this.id,
                    cold:this.value?1:0
                },
                success:(res)=>{
                   if (this.storage!=''){
                    this.$user.delLocalStorage(this.storage);
                   }
                    this.$toast({text:'修改成功',type:'success'});
                }
            });            
        }
    }
}
</script>